﻿/* ==============================================================================
 * 功能描述：LevelConfigProvider  
 * 
 * 创 建 者：郑镇泉
 * 
 * 创建日期：2016/4/22 10:11:40
 * ==============================================================================*/
using UnityEngine;
using System.Collections;

public class LevelConfigProvider : BaseProvider<LevelConfigProvider>
{
    private LevelConfig levelConfig;

    public LevelConfig LevelConfig
    {
        get
        {
            if (levelConfig == null)
            {
                levelConfig = LoadConfig<LevelConfig>("/xml/LevelConfig.xml");
            }
            return levelConfig;
        }
    }

    public LevelConfigLevel[] GetAll()
    {
        return LevelConfig.Items;
    }

    public LevelConfigLevel GetLevelByLv(int lv)
    {
        LevelConfigLevel level = System.Array.Find<LevelConfigLevel>(LevelConfig.Items, (LevelConfigLevel obj) =>
        {
            return int.Parse(obj.lv) == lv;
        });
        if (level == null) Debug.Log("配置表中找不到该等级信息，lv：" + lv);
        return level;
    }
}